/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package BL;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 *
 * @author sundas
 */
@Entity
@Table(name = "department", catalog = "newPurchase", schema = "", uniqueConstraints = {@UniqueConstraint(columnNames = {"DId"})})
@NamedQueries({@NamedQuery(name = "Department.findAll", query = "SELECT d FROM Department d"), @NamedQuery(name = "Department.findByDId", query = "SELECT d FROM Department d WHERE d.dId = :dId"), @NamedQuery(name = "Department.findByDeptName", query = "SELECT d FROM Department d WHERE d.deptName = :deptName"), @NamedQuery(name = "Department.findByDeptDescription", query = "SELECT d FROM Department d WHERE d.deptDescription = :deptDescription"), @NamedQuery(name = "Department.findByIsActive", query = "SELECT d FROM Department d WHERE d.isActive = :isActive")})
public class Department implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "DId", nullable = false)
    private Integer dId;
    @Column(name = "deptName", length = 50)
    private String deptName;
    @Column(name = "deptDescription", length = 150)
    private String deptDescription;
    @Column(name = "isActive", length = 10)
    private String isActive;
    @OneToMany(mappedBy = "dId")
    private Collection<Prodgroup> prodgroupCollection;
    @JoinColumn(name = "inventoryId", referencedColumnName = "inventoryId")
    @ManyToOne
    private Inventory inventoryId;

    public Department() {
    }

    public Department(Integer dId) {
        this.dId = dId;
    }

    public Integer getDId() {
        return dId;
    }

    public void setDId(Integer dId) {
        this.dId = dId;
    }

    public String getDeptName() {
        return deptName;
    }

    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }

    public String getDeptDescription() {
        return deptDescription;
    }

    public void setDeptDescription(String deptDescription) {
        this.deptDescription = deptDescription;
    }

    public String getIsActive() {
        return isActive;
    }

    public void setIsActive(String isActive) {
        this.isActive = isActive;
    }

    public Collection<Prodgroup> getProdgroupCollection() {
        return prodgroupCollection;
    }

    public void setProdgroupCollection(Collection<Prodgroup> prodgroupCollection) {
        this.prodgroupCollection = prodgroupCollection;
    }

    public Inventory getInventoryId() {
        return inventoryId;
    }

    public void setInventoryId(Inventory inventoryId) {
        this.inventoryId = inventoryId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (dId != null ? dId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Department)) {
            return false;
        }
        Department other = (Department) object;
        if ((this.dId == null && other.dId != null) || (this.dId != null && !this.dId.equals(other.dId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "DB.Department[dId=" + dId + "]";
    }

}
